﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using GBlason.Common.CustomCommand;
using GBlason.ViewModel;
using GBlason.ViewModel.General;

namespace GBlason.Control.Aggregate
{
    /// <summary>
    /// Interaction logic for Properties.xaml
    /// </summary>
    public partial class Properties
    {
        public Properties()
        {
            InitializeComponent();
            
        }

        private void CommandBindingCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        private void ShapeChangingExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var command = e.Command as ChangeShapeCommand;
            if (command != null)
                command.Do(new CommandParameter(e.Parameter,GlobalApplicationViewModel.GetApplicationViewModel.CurrentlyDisplayedFile));
        }

        private void ColorChangingExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var command = e.Command as ChangeColorCommand;
            if (command != null)
                command.Do(new CommandParameter(e.Parameter,
                    GlobalApplicationViewModel.GetApplicationViewModel.CurrentlyDisplayedFile,
                    GlobalApplicationViewModel.GetApplicationViewModel.CurrentlyDisplayedFile.CurrentlySelectedComponent as ICommandTarget));
        }
    }
}
